package com.itheima.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.common.PageBean;
import com.itheima.dto.LogDto;
import com.itheima.mapper.LogMapper;
import com.itheima.pojo.OperateLog;
import com.itheima.service.LogService;
import com.itheima.vo.LogVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LogServiceImpl implements LogService {
    @Autowired
    LogMapper logMapper;

    @Override
    public PageBean query(LogDto dto) {
        PageHelper.startPage(dto.getPage(), dto.getPageSize());
        Page<LogVo> query = (Page<LogVo>)logMapper.query(dto);
        long total = query.getTotal();
        List<LogVo> result = query.getResult();
        PageBean pageBean = new PageBean(total, result);
        return pageBean;
    }
}
